package logic

import (
	"context"
	"zhihu/zhihurpc/models/mysql"

	"zhihu/zhihurpc/internal/svc"
	"zhihu/zhihurpc/zhihurpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ProblemanswersLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewProblemanswersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ProblemanswersLogic {
	return &ProblemanswersLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ProblemanswersLogic) Problemanswers(in *zhihurpc.ProblemanswersRequest) (*zhihurpc.ProblemanswersResponse, error) {
	// todo: add your logic here and delete this line
	reply := mysql.Ansewer{
		UserId:    int(in.UserId),
		Content:   in.Content,
		ProblemId: int(in.ProblemId),
	}
	mysql.DB.Debug().Create(&reply)
	return &zhihurpc.ProblemanswersResponse{
		Id: int64(reply.ID),
	}, nil
}
